<?php
$page_title = 'eTAT: My eTAT';
require_once 'controller.php';
$courses = $instructor->getAllCourses();
if($_GET['dc']) {
	$instructor->removeCourse($_GET['dc']);
}
if(isset($_POST['add_course_submit'])) {
	$data = (object) array(
		'title'=>$_POST['title'],
		'term'=>$_POST['term'],
		'description'=>$_POST['description']);
	$id = $instructor->addCourse($data);
	redirect("course.php?c=$id");
}
require_once 'header.php';
?>
<?php include_once('leftmenu.php'); ?>
<div id="main2">
<h1>My eTAT</h1>
<table width="80%" border="0">
	<thead>
		<tr>
			<td align="right" colspan="5"><a href="javascript:void(0);"
				onClick="javascript:popup('add-course',null);"><b>Add New Course</b></a></td>

		</tr>
	</thead>
	<thead>
		<tr>
			<th>Title</th>
			<th>Description</th>
			<th>Date Created</th>
			<th>Term</th>
			<th>Action</th>
		</tr>
	</thead>
	<tbody>
	<?php
	if($courses != null) {
		$count = 0;
		foreach($courses as $c) {


			//$groups = $c->getAllGroups();

			print "<tr>
				<td><a href='./course.php?c=".$c->id."'>".$c->title."</a></td>
				<td>".$c->description."</td>
				<td>".$c->dd."</td>
				<td>".$c->term."</td>
				<!--<td><a href='./myetat.php?dc=".$c->id."'>[Delete]</a><a href='./course.php?md=".$c->id."'>[Modify]</a></td>-->
				<td>
				<a href='javascript:void(0);' onclick='javascript:return sureDel(\"Course\",\"$c->title\",\"./myetat.php?dc=".$c->id."\");'  >[Delete]</a>

				<a href='./course.php?md=".$c->id."'>[Modify]</a></td>

				</tr>";
			$count++;
		}


	}
	?>
	</tbody>
</table>
</div>
<?php require_once 'footer.php'; ?>
<script language="javascript1.3" type="text/javascript">
<!--//

function sureDel(title,value, urlLocation){
	var alertString =  'Are you sure you want to delete "' +title+ '" with value "'+value+'" ';

	if( confirm(alertString) ){

		document.location=urlLocation;
		//return true;
	}
	return false;

}
//-->
</script>

